#include "FiveWin.ch"

//----------------------------------------------------------------------------//

CLASS TRadMenu

   DATA   aItems
   DATA   bSetGet

   METHOD New( nRow, nCol, acItems, bSetGet, oWnd, nHelp ) CONSTRUCTOR
   METHOD nOption( nNewOption ) SETGET
   METHOD Redefine( bSetGet, oWnd, nHelp, aRadioIDs ) CONSTRUCTOR

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New( nRow, nCol, acItems, bSetGet, oWnd, nHelp ) CLASS TRadMenu

   local n

   DEFAULT nHelp := 100

   ::aItems  = {}
   ::bSetGet = bSetGet

   for n = 1 to Len( acItems )
      AAdd( ::aItems, TRadio():New( nRow + n - 1, nCol, acItems[ n ],;
            n == 1,;                // First element is group
            n == Eval( bSetGet ),;  // Is Checked ?
            n, oWnd, Self, nHelp ) )
   next

return

//----------------------------------------------------------------------------//

METHOD nOption( nNewOption ) CLASS TRadMenu

   if nNewOption != nil
      Eval( ::bSetGet, nNewOption )
   else
      return Eval( ::bSetGet )
   endif

return

//----------------------------------------------------------------------------//

METHOD Redefine( bSetGet, oWnd, nHelp, anItemsIDs )  CLASS TRadMenu

   local n

   DEFAULT nHelp := 100

   ::bSetGet     = bSetGet
   ::aItems      = {}

   for n = 1 to len( anItemsIDs )

       aadd( ::aItems, TRadio():Redefine( anItemsIDs[ n ], ;
                               n == Eval( bSetGet ),;  // Is Checked ?
                               n,;
                               oWnd, Self, nHelp ) )
   next

return Self

//---------------------------------------------------------------------------//
